﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;


// 结论对于多字节的添加使用addrange效率要高一些

namespace _关于List添加数据执行效率的测试
{
    class Program
    {
        static void Main(string[] args)
        {
            List<byte> filedatalist = new List<byte>();
            byte []buff = new byte[100000];
#if false
            //00:00:00.0013453
            Stopwatch sw = new Stopwatch();
            sw.Start();
            for (int i = 0; i < buff.Length; i++)
            {
                filedatalist.Add(buff[i]);
            }
            sw.Stop();
            Console.WriteLine(sw.Elapsed);
#else
            //00:00:00.0002625
            Stopwatch sw = new Stopwatch();
            sw.Start();
            filedatalist.AddRange(buff);
            sw.Stop();
            Console.WriteLine(sw.Elapsed);
#endif
            Console.ReadKey();
        }
    }
}
